package com.gci.lib_markdown_editor.viewer

import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.bumptech.glide.Glide
import com.gci.lib_markdown_editor.R
import com.github.chrisbanes.photoview.PhotoView
import java.io.File

class FullscreenImageActivity : AppCompatActivity() {
    private val TAG = "FullscreenImageActivity"
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        window.decorView.systemUiVisibility =
            View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
        supportActionBar?.hide()
        setContentView(R.layout.activity_fullscreen_image)
        val path = intent.getStringExtra("imagePath") ?: return
        val photoView = findViewById<PhotoView>(R.id.photoView)
        Log.i(TAG, "ImagePath:"+ path)
        Log.i(TAG, "ImagePath exist:"+ File(path).exists())
        val realPath = path.replace("local_files/","")
        Glide.with(this)
            .load(File(realPath))
            .into(photoView)

        photoView.setOnClickListener {
            finish() // 点击退出全屏
        }
    }
}